<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>

  function Patient(name,age,gender,height,weight){
    this.name = name
    this.age = age
    this.gender = gender
    this.height = height
    this.weight = weight
  }

  // 返回患者的BMI
  Patient.prototype.bmi=function(){
    return this.weight/(this.height * this.height)
  }



  // 最大心率
  Patient.prototype.maxHeartRate = function(){
    return  220 - this.age
  }

// 心率范围
Patient.prototype.targetHeartRate = function(){
 const maxHeartRate = this.maxHeartRate()
 const minMaxHeartRate = maxHeartRate * 0.5
 const maxMaxHeartRate = maxHeartRate * 0.85
 return `范围是${minMaxHeartRate} - ${maxMaxHeartRate}`

  }

const John = new Patient('John',30,'男',175,75)
console.log(John);
console.log(John.bmi());
console.log(John.targetHeartRate());
</script>
</html>